<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta content="width=device-width,minimum-scale=1.0,maximum-scale=1.0" name="viewport">
<meta content="telephone=no" name="format-detection">
<title>Ajax-Json-Request Test</title>
</head>
<script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/1.9.1/jquery.min.js"></script>
<script type='text/javascript'>
	function execute() {
		clean();
		$.ajax({
			type: "post",
			contentType : 'application/json',
			url: $("#url").val(),
			data: $("#req").val(),
			datatype : "json",
			error: function() {
				$("#res").val("Request Failure!");
			},
			success: function(data) {
				$("#res").val(JSON.stringify(data));
			}
		});
	}
	
	function getDocument() {
		$.ajax({
			type: "post",
			contentType : 'application/json',
			url: $("#url").val()+"?doc",
			error: function() {
				$("#res").val("Request Failure!");
			},
			success: function(data) {
				$("#res").val(data);
			}
		});
	}
	
	function getExample() {
		$.ajax({
			type: "post",
			contentType : 'application/json',
			url: $("#url").val()+"?example",
			error: function() {
				$("#res").val("Request Failure!");
			},
			success: function(data) {
				$("#res").val(data);
			}
		});
	}

	function clean() {
		$("#res").val("");
	}
</script>

<body>
Url:<input type="text" id="url" value="http://localhost:8080/"  style="width:600px"/>
<input type="button" value="测试-返回json" onclick="execute()" />
<input type="button" value="测试-返回txt" onclick="getExample()" />
<hr/>
_Qequest:
<textarea id="req" style="height:200px;width:755px">
{
	"name":"iccboy"
}
</textarea>
<hr/>
Response:
<textarea id="res" style="height:200px;width:755px">
该页面主要用于测试ajax的json数据格式的请求与响应。
</textarea>
</body>
</html>